//
//  HBHMainResumeCell.m
//  HubeiHotel
//
//  Created by 张露杰 on 17/11/15.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "HBHMainResumeCell.h"

@implementation HBHMainResumeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    //    继承父类
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
    }
    return self;
}

-(void)loadCellWithData:(NSDictionary *)data
{
    //    重新布局
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
//     [cell loadCellWithData:@{@"title":@"软件开发工程师",@"money":@"5-10K",@"adress":@"洪山区",@"workage":@"3-5年",@"qualification":@"本科",@"marks":@[@"媒体",@"主管",@"顾问",@"公共关系"]}];
    NSString *title = data[@"name"];
    NSString *money = data[@"salary"];
    NSString *adress= data[@"areaName"];
    NSString *workage = data[@"workingLife"];
    NSString *qualification = data[@"education"];
    NSString *time = [TomamaUI dateTostiring:[TomamaUI getDateWithStringNo8:data[@"createDate"]] andString:@"MM月dd日"];
    NSMutableArray *marks = [data[@"keyword"] componentsSeparatedByString:@","].mutableCopy;
    if (!marks.count) {
        [marks addObject:[ToolViewVC getNotNullStr:data[@"keyword"]]];
    }
    
    UILabel *titleLabel = [TomamaUI createLabel:CGRectMake(16*screenW_6, 16*screenW_6, [TomamaUI getStringWeithtWith:title andHeigth:18*screenW_6 andFont:[UIFont systemFontOfSize:19*screenW_6]], 19*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:19*screenW_6] textColor:TextBlack text:title];
    [self.contentView addSubview:titleLabel];
    
    UILabel *moneyLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(titleLabel.frame), 17*screenW_6, SCREENW - CGRectGetMaxX(titleLabel.frame) - 16*screenW_6, 17*screenW_6) textAligment:2 font:[UIFont systemFontOfSize:17*screenW_6] textColor:[UIColor colorWithHexString:@"#fe6905"] text:money];
    [self.contentView addSubview:moneyLabel];
    
    UILabel *adressLabel = [TomamaUI createLabel:CGRectMake(16*screenW_6, CGRectGetMaxY(titleLabel.frame) + 14*screenW_6, [TomamaUI getStringWeithtWith:adress andHeigth:13*screenW_6 andFont:[UIFont systemFontOfSize:13*screenW_6]], 13*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:13*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:adress];
    [self.contentView addSubview:adressLabel];
    
    UIView *lineView1 = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(adressLabel.frame) + 10*screenW_6, adressLabel.frame.origin.y, 1, adressLabel.frame.size.height)];
    lineView1.backgroundColor = [UIColor colorWithHexString:@"#666666"];
    [self.contentView addSubview:lineView1];
    
    UILabel *workAgeLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(lineView1.frame) + 10*screenW_6, adressLabel.frame.origin.y, [TomamaUI getStringWeithtWith:workage andHeigth:13*screenW_6 andFont:[UIFont systemFontOfSize:13*screenW_6]], 13*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:13*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:workage];
    [self.contentView addSubview:workAgeLabel];
    
    UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(workAgeLabel.frame) + 10*screenW_6, adressLabel.frame.origin.y, 1, adressLabel.frame.size.height)];
    lineView2.backgroundColor = [UIColor colorWithHexString:@"#666666"];
    [self.contentView addSubview:lineView2];
    
    UILabel *qualificationLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(lineView2.frame) + 10*screenW_6, adressLabel.frame.origin.y, [TomamaUI getStringWeithtWith:qualification andHeigth:13*screenW_6 andFont:[UIFont systemFontOfSize:13*screenW_6]], 13*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:13*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:qualification];
    [self.contentView addSubview:qualificationLabel];
    
    UILabel *timeLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(qualificationLabel.frame), adressLabel.frame.origin.y, SCREENW - CGRectGetMaxX(qualificationLabel.frame) - 16*screenW_6, 13*screenW_6) textAligment:2 font:[UIFont systemFontOfSize:13*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:time];
    [self.contentView addSubview:timeLabel];
    
    UILabel *lastLabel;
    for (int i = 0; i < marks.count; i++) {
        UILabel *markLabel;
        if (i == 0) {
            markLabel = [TomamaUI createLabel:CGRectMake(16*screenW_6, CGRectGetMaxY(adressLabel.frame) + 13*screenW_6, [TomamaUI getStringWeithtWith:marks[i] andHeigth:23*screenW_6 andFont:[UIFont systemFontOfSize:11*screenW_6]] + 18*screenW_6, 23*screenW_6) textAligment:1 font:[UIFont systemFontOfSize:11*screenW_6] textColor:[UIColor colorWithHexString:@"#42afb8"] text:marks[i]];
        }else{
            markLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(lastLabel.frame) + 6*screenW_6, lastLabel.frame.origin.y, [TomamaUI getStringWeithtWith:marks[i] andHeigth:23*screenW_6 andFont:[UIFont systemFontOfSize:11*screenW_6]] + 18*screenW_6, 23*screenW_6) textAligment:1 font:[UIFont systemFontOfSize:11*screenW_6] textColor:[UIColor colorWithHexString:@"#42afb8"] text:marks[i]];
        }
        markLabel.layer.masksToBounds = YES;
        markLabel.layer.cornerRadius = 5*screenW_6;
        markLabel.layer.borderColor = [UIColor colorWithHexString:@"#a0d7db"].CGColor;
        markLabel.layer.borderWidth = .5;
        [self.contentView addSubview:markLabel];
        lastLabel = markLabel;
    }
    
    UIView *lineView =[[UIView alloc]initWithFrame:CGRectMake(0, 108*screenW_6 - .5, SCREENW, .5)];
    lineView.backgroundColor = backColor;
    [self.contentView addSubview:lineView];
}

@end
